#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Time       :   8:59
# Author     : Y4
# Site       : 
# File       : 013 协程 第三方库.py
# Software   : PyCharm

'''
greenlet 完成协程任务
'''

import time
import greenlet


def test1():
    for i in range(5):
        print('a'+str(i))
        time.sleep(1)
        g2.switch()


def test2():
    for i in range(5):
        print('b'+str(i))
        time.sleep(2)
        g1.switch()


if __name__ == '__main__':
    g1 = greenlet.greenlet(test1)
    g2 = greenlet.greenlet(test2)
    g1.switch()